package Navigation;

import Controller.MainController;
import Controller.MainState.NoUserState;
import Controller.User.UserType;
import Page.AboutUs.*;
import Page.AcademicInfoPage.AcademicInfoPage;
import Page.AchievementPage.AchievementPage;
import Page.BookBorrowingRecordPage.BookBorrowingRecordPage;
import Page.DownloadPage.DownloadPage;
import Page.EnrollmentInformationPage.DoctoralPage;
import Page.EnrollmentInformationPage.InternationalPage;
import Page.EnrollmentInformationPage.MasterPage;
import Page.EnrollmentInformationPage.UndergraduatePage;
import Page.HelpPage;
import Page.InternationalCooperation.InternationalCooperationPage;
import Page.LoginAndExitRecordPage.InAndOutPage;
import Page.LoginInterfacePage.LoginInterfacePage;
import Page.NewsFeedPage.NewsFeedPage;
import Page.NoticeInfoPage.NoticeInfoPage;
import Page.PaperPage.PaperPage;
import Page.PersonalInformationPage.StudentPersonalInformationPage;
import Page.PersonalInformationPage.TeacherPersonalInformationPage;
import Page.Research.Copy.CopyPage;
import Page.ResearchInfoPage.ResearchInfoPage;
import Page.Teaching.Papers.PapersPage;
import Page.Teaching.Reform.ReformPage;
import Page.Teaching.Result.ResultPage;
import Page.Teaching.Textbook.TextbookPage;
import Page.TeachingInfoPage.TeachingInfoPage;
import Page.UserManagementPage;
import Util.AlertUtil;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class Navigation {
    public static void ToPage(String page){
        switch (page){
            case "首页":
            {
                //TODO
                break;
            }
            case "研究所简介":
            {
                NavigationController.addScene(ResearchInstituteInfoPage.getScene());
                break;
            }
            case "全职教师":
            {
                NavigationController.addScene(Page.TeacherAndStudentPage.FullTimeTeacherPage.getScene());
                break;
            }
            case "兼职教师":
            {
                NavigationController.addScene(Page.TeacherAndStudentPage.PartTimeTeacherPage.getScene());
                break;
            }
            case "在读学生":
            {
                NavigationController.addScene(CurrentStudentPage.getScene());
                break;
            }
            case "毕业学生":
            {
                NavigationController.addScene(GraduatePage.getScene());
                break;
            }
            case "联系我们":
            {
                NavigationController.addScene(ContactUsPage.getScene());
                break;
            }
            case "新闻动态":
            {
                NavigationController.addScene(NewsFeedPage.getScene());
                break;
            }
            case "通知通告":
            {
                NavigationController.addScene(NoticeInfoPage.getScene());
                break;
            }
            case "学术活动":
            {
                NavigationController.addScene(AcademicInfoPage.getScene());
                break;
            }
            case "教学工作":
            {
                NavigationController.addScene(TeachingInfoPage.getScene());
                break;
            }
            case "科研工作":
            {
                NavigationController.addScene(ResearchInfoPage.getScene());
                break;
            }
            case "教学成果":
            {
                NavigationController.addScene(ResultPage.getScene());
                break;
            }
            case "教学论文":
            {
                NavigationController.addScene(PapersPage.getScene());
                break;
            }
            case "教学教材":
            {
                NavigationController.addScene(TextbookPage.getScene());
                break;
            }
            case "教学教改":
            {
                NavigationController.addScene(ReformPage.getScene());
                break;
            }
            case "科研成果":
            {
                NavigationController.addScene(Page.Research.Result.ResultPage.getScene());
                break;
            }
            case "科研论文":
            {
                NavigationController.addScene(PaperPage.getScene());
                break;
            }
            case "科研专利":
            {

                NavigationController.addScene(AchievementPage.getScene());
                break;
            }
            case "科研著作权":
            {
                NavigationController.addScene(CopyPage.getScene());
                break;
            }
            case "本科生":
            {
                NavigationController.addScene(UndergraduatePage.getScene());
                break;
            }
            case "硕士生":
            {
                NavigationController.addScene(MasterPage.getScene());
                break;
            }
            case "博士生":
            {
                NavigationController.addScene(DoctoralPage.getScene());
                break;
            }
            case "留学生":
            {
                NavigationController.addScene(InternationalPage.getScene());
                break;
            }
            case "国际合作":
            {
                NavigationController.addScene(InternationalCooperationPage.getScene());
                break;
            }
            case "签到签出":
            {
                if(MainController.getCurrentState().ifCanGetInAndOutInformation())
                {
                    NavigationController.addScene(InAndOutPage.getScene());
                }else{
                    AlertUtil.showAlert("提示","尚未登录教师账户");
                }
                break;
            }
            case "图书管理":
            {
                if(MainController.getCurrentState().ifCanGetBookInformation())
                {
                    NavigationController.addScene(BookBorrowingRecordPage.getScene());
                }else{
                    AlertUtil.showAlert("提示","尚未登录账户");
                }
                break;
            }
            case "开题资料":
            {

            }
            case "中期资料":
            {

            }
            case "答辩资料":
            {

            }
            case "学位论文":
            {

            }
            case "专利资料":
            {

            }
            case "会议资料":
            {

            }
            case "上级文件":
            {

            }
            case "其他资料":
            {
                if(MainController.getCurrentState().ifCanGetDownloadInformation())
                {
                    NavigationController.addScene(DownloadPage.getScene());
                }else{
                    AlertUtil.showAlert("提示","请先登录");
                }
                break;
            }
            case "用户帮助":
            {
                if(MainController.getCurrentState().ifCanGetUserHelpInformation())
                {
                    NavigationController.addScene(HelpPage.getScene());
                }else{
                    AlertUtil.showAlert("提示","请先登录");
                }
                break;
            }
            case "登录":
            {
                Stage stage = new Stage();
                stage.initModality(Modality.WINDOW_MODAL);
                stage.initOwner(NavigationController.getLastScene().getWindow());
                stage.setTitle("登录界面");
                stage.setScene(LoginInterfacePage.getScene());
                stage.showAndWait();
                break;
            }
            case "登出":
            {
                // 登出
                if(MainController.getCurrentState() instanceof NoUserState)
                {
                    AlertUtil.showAlert("提示","请先登录");
                }else{
                    MainController.logout();
                }
                break;
            }
            case "个人信息":
            {
                if(MainController.getUserType() == UserType.MANAGER)
                {
                    Stage stage = new UserManagementPage().getState();
                    stage.initModality(Modality.WINDOW_MODAL);
                    stage.initOwner(NavigationController.getLastScene().getWindow());
                    stage.showAndWait();
                    break;
                }

                if(MainController.getCurrentState().ifCanGetDetailInformation())
                {
                    if(MainController.getUserType() == UserType.STUDENT)
                    {
                        NavigationController.addScene(StudentPersonalInformationPage.getScene());
                    }else{
                        NavigationController.addScene(TeacherPersonalInformationPage.getScene());
                    }
                }else{
                    AlertUtil.showAlert("提示","请先登录");
                }
                break;
            }
            default:{
                System.err.println("页面导航出现错误");
                break;
            }
        }
    }
}
